COM AT+CNMI - New Message indication
COM Version 1.0		21.02.05	T. Kleinmann
COM Version 1.01	24.05.06	C.Grzegorczyk

from attglobals import *
import SMS_PDU_processing

COM Activate extended error messages in text mode
AT+CMEE=2
WAIT FOR OK

COM Reset to default values to ensure integrated test
ATCMD(1,'AT&F')
WAIT FOR OK

AT+CNMI=?
WAITFOR (1,'+CNMI:')

COM Activate Phase 2+ compatibility
AT+CSMS=1

COM No storing of SMS
AT+CNMI=1,1
WAIT FOR OK

COM Query
AT+CNMI?
WAITFOR (1,'1,1')

COM Change preferred SMS message storage
AT+CPMS='ME','ME','ME'
WAIT FOR OK


Message Please send SMS to the Primary MobilePhone and press OK after that

# Prepare PDU processing
##PduProcessor=SMS_PDU_processing.CPdu()

# This is the text for SMS
##TEXT1 = 'Test'

# create corresponding PDUs for later use
##strPDU_TEXT1=PduProcessor.ConvertASCII2PDU(TEXT1)

# create PDU from TEXT1
##PduProcessor.m_strServiceCenterAddress=strSCA
##PduProcessor.m_strDestinationAddress=PrimaryMobilePhoneNumber
##PduProcessor.m_strUserData=TEXT1
##iPduLen=PduProcessor.CreateSubmitPDU()
##strSubmitPDU_TEXT1=PduProcessor.m_strCurrentPDU

##COM ('Message text in PDU format: ', PduProcessor.m_strCurrentPDU, ' length: ', iPduLen)

# Send SMS 
##AT+CMGS=iPduLen
##WAITFOR >
##ATCMD (1, PduProcessor.m_strCurrentPDU, chr(26))
##strCMGWResult=WAITFOR (1, 'OK')

WAITFOR (1,'+CMTI:')

AT+CNMI=1,2
WAIT FOR OK

WAIT 10000

COM <H2> PDU converter doesn't work properly, SMS are send from another phone, not from script
Message Please send SMS to the Primary MobilePhone and press OK after that

# Send SMS 
##AT+CMGS=iPduLen
##WAITFOR >
##COM now write PDU to mobile, including trailing CTRL-Z (ASCI 26)
##ATCMD (1, PduProcessor.m_strCurrentPDU, chr(26))
##strCMGWResult=WAITFOR (1, 'OK')

WAITFOR (1,'+CMT:')

AT
WAIT FOR OK
